public class Solution {

    public double pow (double base, int exponent) {
      double res = 1;
      while (exponent != 0) {
        if ((exponent & 1) == 1) {
          res *= base;
        }
        base *= base;
        exponent >>= 1;
        System.out.printf("%f, %f\n", res, base);
      }
      return res;
    }

    public double Power(double base, int exponent) {
      /*
      double ret = 1;
      if (exponent > 0) {
        for (int i = 0; i < exponent; i++) {
          ret *= base;
        }
      }
      else {
        for (int i = 0; i < -exponent; i++) {
          ret *= base;
        }
        ret = 1 / ret;
      }
      return ret;
      */

      // 快速幂
      if (exponent < 0) {
        base = 1 / base;
        exponent = -exponent;
      }

      return pow(base, exponent);
  }
}
